import { request, login, formdataRequest } from './request.js';

//我的运动记录
export function motionRecord(num) {
	return request({
		url: "/motionRecord/page",
		data: {
			num
		}
	})
}

//添加运动评估
export function addMotionAess(payload) {
	return request({
		url: "/motionAssessment/save",
		method: "POST",
		data: payload
	})
}


//我的运动评估
export function motionAssess(current, size) {
	return request({
		url: "/motionAssessment/page",
		data: {
			current,
			size
		}
	})
}

//运动处方分类
export function motionClassify(options) {
	return request({
		url: "/motionPrescription/page",
		data: {
			current: options.current,
			size: options.size,
			type: options.type,
			parentId: options.parentId,
			name: options.name
		}
	})
}

//运动详情
export function motionDetail(prescriptionId) {
	return request({
		url: "/motionPrescriptionDetails/getOneByPrescriptionId",
		data: {
			prescriptionId
		}
	})
}

//我的运动列表
export function myMotionList() {
	return request({
		url: "/motionProgramme/page",
		data: {
			current: 1,
			size:10
		}
	})
}

//新增我的运动
export function addMyMotionList(payload) {
	return request({
		url: "/motionProgramme/save",
		method: "POST",
		data: payload
	})
}

//运动日志
export function motionLog(year, month) {
	return request({
		url: "/motionLog/page",
		data: {
			year,
			// month
		}
	})
}

//新增运动记录
export function addMotionLog(data) {
	return request({
		url: "/motionRecord/save",
		method: "POST",
		data
	})
}

//获取手机号
export function getPhoneNumber(code) {
	return request({
		url: "/wx/findPhone",
		data: {
			code
		}
	})
}

//获取用户信息
export function getUserInfo() {
	return request({
		url: "/user/getSysUser",
	})
}

//修改用户信息
export function setUserInfo(payload) {
	return request({
		url: "/user/updUser",
		method: "POST",
		data: payload
	})
}

//紧急联系人列表
export function getContactsList(cur, size) {
	return request({
		url: `/contacts/page?current=${cur}&size=${size}`,
	})
}

//新增紧急联系人
export function addContacts(payload) {
	return request({
		url: `/contacts/add`,
		method: "post",
		data: payload
	})
}

//删除紧急联系人
export function delContacts(id) {
	return formdataRequest({
		url: `/contacts/del`,
		method: "post",
		data: id
	})
}

//统计天数
export function queryStatistics(payload) {
	return request({
		url: `/motionLog/queryStatistics`,
		data: payload
	})
}


//新闻分类
export function newsTypes(payload) {
	return request({
		url: `/essayType/page`,
		data: payload
	})
}

//新闻查询分类
export function newsTypesQuery(payload) {
	return request({
		url: `/essay/page`,
		data: payload
	})
}

//新闻详情
export function newsDetail(id) {
	return request({
		url: `/essay/getOne`,
		data: {
			id
		}
	})
}

//判断账号是否存在
export function isAccountExist(userName) {
	return request({
		url: `/user/isExist`,
		data: {
			userName
		}
	})
}

//新增用户
export function addAccount(payload) {
	return request({
		url: `/user/addUser`,
		method: "post",
		data: payload
	})
}

//查询单个运动方案所关联的运动方案详情
export function queryMotionDetail(id) {
	return request({
		url: `/motionProgramme/findDetailsById`,
		data: {
			id
		}
	})
}

//获取首页运动次数百分比
export function getIndexMotionCount() {
	return request({
		url: `/motionRecord/numberProportion`
	})
}

//删除我的运动
export function deleteMyMotion(id) {
	return formdataRequest({
		url: `/motionProgramme/del`,
		method: 'post',
		data: {
			id
		}
	})
}